﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using TheDrinksApp.Models;
using TheDrinksApp.Database;

namespace TheDrinksApp.Screen.Home
{
    public partial class ItemSearch : UserControl
    {
        private Drink drink = new Drink();

        public Drink Drink
        {
            get { return drink; }
            set
            { 
                drink = value;
                txtDrinkName.Text = drink.DrinkName.ToUpper();
            }
        }

        public ItemSearch(Drink drink)
        {
            InitializeComponent();
            this.Drink = drink;
        }

        public delegate void ShowOrderScreenHandler(Drink d);
        public event ShowOrderScreenHandler ShowOrderScreen;

        public delegate void ShowMixerScreenHandler(Drink d);
        public event ShowMixerScreenHandler ShowMixerScreen;

        private void txtDrinkName_Tap(object sender, GestureEventArgs e)
        {
            
        }

        private void btnGoToDetail_Click(object sender, RoutedEventArgs e)
        {
            if (Util.currentOrder.category.CatergoryID == -1)
            {
                Util.currentOrder.category = Util.GetCategoryByID(this.drink.CatergoryID)[0];
            }
            Util.currentOrder.drink = this.drink;
            if (Util.currentOrder.category.Catergory.ToUpper().Equals(GlobalVariable.SPIRITS))
            {
                ShowMixerScreen(this.Drink);
            }
            else
            {
                ShowOrderScreen(this.Drink);
            }
        }
    }
}
